//
//  HCSystemMessageViewController.m
//  HappyChildren
//
//  Created by WillyZhao on 2017/1/19.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCSystemMessageViewController.h"

#import "HCMessageShopSysView.h"

#import "HCMsgCenterModel.h"

@interface HCSystemMessageViewController () <HCMessageShopSysViewSurePay> {
    NSString *promptString;
}

@end

@implementation HCSystemMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    promptString = [NSString stringWithFormat:@"%@",self.parameterObject];
    
    if ([promptString isEqualToString:@"system"]) {
        self.textTitle = @"系统消息";
    }else{
        self.textTitle = @"店铺消息";
    }
    
    HCMsgCenterData *data = (HCMsgCenterData *)self.dataObject;
    
    HCMessageShopSysView *vc = [[HCMessageShopSysView alloc] initWithFrame:CGRectMake(0, 0, self.centerView.frame.size.width, self.centerView.frame.size.height) andPromptString:promptString dataID:data];
    vc.delegate = self;
    [self.centerView addSubview:vc];
    
    self.dataRequest.delegate = self;
    
    // Do any additional setup after loading the view.
}

-(void)surePay:(NSString *)shop_id {
    [self.dataRequest postHC_SurePay:HCGETUSER(@"userid")];
}

-(void)dataRequesterFinish:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveDictionary:(NSDictionary *)dictionary {
    NSLog(@"确认消费成功:%@",dictionary);
    
    if ([dictionary[@"stat"] integerValue] == 200) {
        [self.navigationController popViewControllerAnimated:YES];
        [XHToast showBottomWithText:@"确认消费成功"];
    }else{
        [XHToast showBottomWithText:@"确认消费失败"];
    }
    
}

-(void)dataRequesterFail:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveErrorDictionary:(NSDictionary *)dictionary {
    NSLog(@"确认消费失败");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
